﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<CRM.Database.Model.Customers>" %>
<%@ Import Namespace="CRM.Database.Model" %>
<%@ Import Namespace="CRM.Resourses" %>

<% Html.DevExpress().GridView(settings =>
                                    {
                                        settings.Name = "gdCustomersProductSystems";
                                        settings.KeyFieldName = "IdCustomersProductSystem";
                                        settings.CallbackRouteValues =
                                            new
                                                {
                                                    Controller = "Customers",
                                                    Action = "ProductSystemsEdit",
                                                    idCustomer = Model.IdCustomer
                                                };
                                        settings.SettingsPager.PageSize = 20;
                                        settings.Width = Unit.Percentage(100);


                                        settings.Columns.Add(column =>
                                                                 {
                                                                     column.Caption = Resourses.ProductSystem;
                                                                     column.FieldName = "ProductSystemNameLocalized";
                                                                     column.EditFormSettings.Visible =
                                                                         DefaultBoolean.False;
                                                                 });

                                        settings.Columns.Add(column =>
                                                                 {
                                                                     column.Caption = Resourses.ProductMark;
                                                                     column.FieldName = "ProductMarkExt";
                                                                     column.EditFormSettings.Visible =
                                                                         DefaultBoolean.False;
                                                                 });

                                        settings.Columns.Add(column =>
                                                                 {
                                                                     column.Caption = Resourses.ProductSystemRu;
                                                                     column.FieldName = "IdProductSystem";
                                                                     column.Visible = false;
                                                                     column.EditFormSettings.Visible =
                                                                         DefaultBoolean.True;
                                                                     column.ColumnType = MVCxGridViewColumnType.ComboBox;
                                                                     var comboBoxProperties =
                                                                         column.PropertiesEdit as ComboBoxProperties;
                                                                     if (comboBoxProperties != null)
                                                                     {
                                                                         var col = new ProductSystemsCollection();
                                                                         comboBoxProperties.Width = 600;
                                                                         comboBoxProperties.DropDownStyle =
                                                                             DropDownStyle.DropDownList;
                                                                         comboBoxProperties.DataSource =
                                                                             col.ProductSystemsActiveList;
                                                                         //comboBoxProperties.TextField = "ProductSystemRu";
                                                                         comboBoxProperties.ValueField =
                                                                             "IdProductSystem";
                                                                         comboBoxProperties.ValueType = typeof (int);
                                                                         //comboBoxProperties.Columns.Add("ProductSystemRu", Resourses.ProductSystemRu);
                                                                         //comboBoxProperties.Columns.Add("ProductSystemDe", Resourses.ProductSystemDe);
                                                                         //comboBoxProperties.Columns.Add("ProductSystemEn", Resourses.ProductSystemEn);
                                                                         //comboBoxProperties.Columns.Add("ProductSystemSAP", Resourses.ProductSystemSAP);
                                                                         comboBoxProperties.Columns.Add("ProductSystemNameLocalized",Resourses.ProductSystem);
                                                                         comboBoxProperties.Columns.Add("ProductMarkExt", Resourses.ProductMark);
                                                                     }
                                                                 });

                                        settings.CommandColumn.Visible = true;
                                        settings.CommandColumn.NewButton.Visible = true;
                                        settings.CommandColumn.DeleteButton.Visible = true;
                                        settings.CommandColumn.EditButton.Visible = false;
                                        settings.SettingsBehavior.ConfirmDelete = true;
                                        settings.Settings.ShowFilterRow = false;
                                        //var cp = Model.CustomersProductSystems.FirstOrDefault();
                                        //if (cp == null)
                                        //    cp = new CustomersProductSystems();
                                        //if (cp != null)
                                   //     {
                                            settings.SettingsEditing.AddNewRowRouteValues =new{Controller = "Customers",Action = "CustomersProductSystemsAdd",idCustomer = Model.IdCustomer};
                                       
                                        settings.SettingsEditing.DeleteRowRouteValues =new{Controller = "Customers",
                                                    Action = "CustomersProductSystemsDelete",
                                                    idCustomer = Model.IdCustomer
                                                };
                               //     }

}).Bind(Model.CustomersProductSystems.ToList()).GetHtml();%>